/**
 * Created by Administrator on 2019/5/18 0018.
 */
/**
 * Created by Administrator on 2019/5/17/017.
 * //添加多边形
 //id: 服务化平台给出的UUID，字符串
 //name：多边形名称，可以为空
 //points: 多边形的经纬高数组顺时针或逆时针输入，格式为[经,纬,高,经,纬,高,经,纬,高,...]
 //fillColor：多边形填充颜色，数组：[R,G,B,255]（[255,0,0,255]）
 //isFilled：多边形是否填充，true or false
 //isOutline：多边形是否显示轮廓，true or false
 //outlineColor：多边形轮廓颜色，数组：[R,G,B,255]（[255,0,0,255]）
 */
import CZML_GENERALTOOLS_CLASS from "./../main/CZML_GENERALTOOLS_CLASS.js"

class CZML_Polygon {
    constructor(viewer, id, name, points, fillColor, isFilled, isOutline, outlineColor) {
        this._viewer = viewer
        this.id = id
        this.name = name
        this.points = points
        this.fillColor = fillColor
        this.isFilled = isFilled
        this.isOutline = isOutline
        this.outlineColor = outlineColor
        this.polygon = {
            id: id,
            name: name,
            polygon: {
                show: true,
                height: 0,
                positions: {
                    cartographicDegrees: points
                },
                material: {
                    solidColor: {
                        color: {
                            rgba: fillColor
                        }
                    }
                },
                fill: isFilled,
                outline: isOutline,
                outlineColor: {
                    rgba: outlineColor
                }
            }
        }


        this.CZML_AddPolygon()
    }

    CZML_AddPolygon() {
        // 插入该数据对象
        const ret = CZML_GENERALTOOLS_CLASS.InsertModelObjectInformation(this.id, this.polygon, true)
        // 上图
        CZML_GENERALTOOLS_CLASS.Upper(this._viewer)
        return ret
    }
}
export default CZML_Polygon
